﻿// EnvelopeControl.xaml.cs (c) Copyright 2009, Mike Hodnick : www.hodnick.com

using System.Windows.Controls;
using System.Windows.Media;
using Kindohm.KSynth.Library;

namespace Kindohm.KSynth.AudioCanvas
{
    public partial class EnvelopeControl : UserControl, ICanvasControl
    {
        Envelope envelope;

        public EnvelopeControl()
        {
            InitializeComponent();
        }

        public Color Color
        {
            get
            {
                return ((SolidColorBrush)this.ellipse.Stroke).Color;
            }
            set
            {
                this.ellipse.Stroke = new SolidColorBrush(value);
                this.attackLabel.Foreground = new SolidColorBrush(value);
                this.sustainLabel.Foreground = new SolidColorBrush(value);
                this.releaseLabel.Foreground = new SolidColorBrush(value);
                this.attackUpDown.Foreground = new SolidColorBrush(value);
                this.sustainUpDown.Foreground = new SolidColorBrush(value);
                this.releaseUpDown.Foreground = new SolidColorBrush(value);
                this.title.Foreground = new SolidColorBrush(value);
            }
        }

        public Envelope Envelope
        {
            get { return this.envelope; }
            set
            {
                this.envelope = value;
                this.envelope.SetAttack(
                    this.attackUpDown, NumericUpDown.ValueProperty);
                this.envelope.SetSustain(
                    this.sustainUpDown, NumericUpDown.ValueProperty);
                this.envelope.SetRelease(
                    this.releaseUpDown, NumericUpDown.ValueProperty);
            }
        }

        public TranslateTransform Translation
        {
            get { return this.translation; }
        }
    }
}
